<?php
	function newUser() {
		$shopArr = array(
							"id"            => "9999999",
							"delivery"      => null,
							"name"          => $_SESSION['shopName'],
							"address"       => $_SESSION['shopCity'].", ".$_SESSION['shopAddress'],
							"phone"         =>$_SESSION['phone'],
							"shop_promo"    => null );

		$shop = new Shop($shopArr);

		$companyArr = array (
							"id"            => "9999999",
							"name"          => $_SESSION['companyName'],
							"address"       => $_SESSION['companyCity'].", ".$_SESSION['companyAddress'],
							"Resp_official" => $_SESSION['respOfficial'],
							"shops"         => array($shop) );


		$company[] = new Company($companyArr);

		$userArr = array(   "id"            => "9999999",
							"first_name"    => $_SESSION['fname'],
							"last_name"     => $_SESSION['lname'],
							"password"      => $_SESSION['pass'],
							"email"         => $_SESSION['email'],
							"new_password"  => null,
							"status"        => "not approved",
							"privileges"    => "user");

		$user = new User($userArr);
		$user->setCompanies($company);
		$factory = Factories::Init();
		$db      = $factory->databaseObject("insert", "user");

		try {
			$db->execute($user);
		}
		catch (Exception $e) {
			return false;
		}
		return TRUE;
	}

?>
